<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${sql.namespace}">
	
	<insert id="insert${sql.className}" parameterType="${sql.className}" flushCache="true" useGeneratedKeys="true" keyProperty="${sql.pkName}">
		insert into ${sql.tableName}(
			<#list mm.fields as field>
			<#if field.fieldName != sql.pkName>
			${field.fieldColumn}<#sep>,
			</#if>
			</#list>
			${"\n\t\t"}) values(
			<#list mm.fields as field>
			<#if field.fieldName != sql.pkName>
			${"#{"}${field.fieldName}}<#sep>,
			</#if>
			</#list>
			${"\n\t\t"})
	</insert>
	
	<update id="update${sql.className}" parameterType="${sql.className}" flushCache="true">
		update ${sql.tableName} set 
			<#list mm.fields as field>
			<#if field.fieldName != sql.pkName>	
			<if test='null != ${field.fieldName}<#if field.fieldType == 'String'> and "" != ${field.fieldName}</#if>'>
			${field.fieldColumn} = ${"#{"}${field.fieldName}},
			</if>
			</#if>
			</#list>
			${sql.pkColumn} = ${"#{"}${sql.pkName}${"}"}
		where ${sql.pkColumn} = ${"#{"}${sql.pkName}}
	</update>
	
	<select id="queryAll" resultType="${sql.className}" useCache="true">
		select * from ${sql.tableName}
	</select>
	
</mapper>